-
Notifications
You must be signed in to change notification settings - Fork 467
Feature/qr code server #1652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/qr code server #1652
Conversation
|
Address issue #919 |
|
Very cool. Thanks for the PR. |
-Removed extra comments
-Added info when loaded
-Removed wrong validation
- implement create_qr - implemented simple happy path unit test
- Added base64 output
- Added error handling
- Added png, svg and ascii formats
- Added tests to cover generator changes
- It will check if user input has filename on it
- check if filename.ext has the correct ext
- It creates the output folder if it does not exist
- save method added to allow use as qrcode image
- Uses qrcode image factory to generate images
- Removed ascii logic from generator
- improved output path handling
- remove code used to run locally
- test for multiple formats PNG, SVG, ASCII
- test for error handling
- test create qr base64
Added a server test to list tools
…anage the following cases
- case 1: output_path is a folder
- case 2: output_path has file extension
- case 3: output_path has filename without extension
- case 4: output_path does not have filename
- Decoupled qr image generation from the create_qr_code
- Improved Ascii save to handle BytesIO for batch zip generation
- Handle errors
- Added tests to get 100% coverage
- Test manually to check created files
- changed ascii filename to have extension ascii
- Created a image generator to handle batch
- handled errors
- changed ascii format to have ascii extension
- Added Log when successfull
- added log for success false
…t_path Fix edge cases in file path resolution: - Handle filenames with non-matching extensions (e.g., file.jpg -> file.jpg.png) - Handle filenames ending with dot (e.g., weird. -> weird.png) - Only skip extension appending when existing extension matches target format Signed-off-by: Mihai Criveti <[email protected]>
Security fixes: - Fix Containerfile build order (copy src/ before pip install) - Add path traversal validation for naming_pattern to prevent zip-slip Correctness fixes: - Populate file_path, zip_file_path, output_directory in responses - Use config values for batch defaults (size, output_directory, zip_output) - Use config.decoding.preprocessing_enabled as default - Fix wrong request names in logging (decode/validate used batch name) - Convert NumPy arrays to lists for JSON serialization - Fix README to show correct zip filename (qr.zip not qr_batch.zip) - Fix test using wrong field name (version -> target_version) Signed-off-by: Mihai Criveti <[email protected]>
Validation fixes: - Preserve whitespace in QR data (don't strip during validation) - Clamp border to valid range [0, 100] (was only capping max) - Add image_format validation against config.supported_image_formats - Consistent data length validation in batch (use actual length) Container fixes: - Switch to opencv-python-headless (works on slim containers) Test additions: - Add tests for naming_pattern path traversal rejection - Add tests for border validation clamping Code cleanup: - Remove unnecessary UTF-8 encoding declarations (ruff UP009) Signed-off-by: Mihai Criveti <[email protected]>
…rrection Fixes: - Add border and error_correction to BatchQRGenerationRequest model - Pass border/error_correction to index_image_generator - Add format validation to single QR generation (consistency with batch) - Update server.py to expose border/error_correction for batch Documentation: - Update README examples to match actual output format - Document that image_format is validation-only (auto-detection used) - Add border/error_correction parameters to batch docs Test fix: - Use == instead of is for string comparison in format test Signed-off-by: Mihai Criveti <[email protected]>
6e7b68b to
9df68eb
Compare
|
Thanks @cafalchio for this great contribution! 🎉 I've rebased the branch onto main and made some fixes to address issues found during review. Here's a summary of the changes: Security Fixes
Correctness Fixes
Documentation
Tests
All 97 tests passing with 94% coverage - awesome! |
|
Hi @crivetimihai, thank you very much for fixing it. I am glad to have made my first contribuition. :) |
|
Thank you for contributing, great PR / MCP Server! |
Summary
This PR adds a MCP Server in Python that provides QR code generation and decoding capabilities. - closes #919
Server Details
mcp-servers/python/qr_code_server/generate_qr_code: Generate QR codes from text or datadecode_qr_code: Decode QR codes from image filesgenerate_batch_qr_codes: Generate multiple QR codes efficientlyvalidate_qr_data: Validate and analyze QR code data before generationTesting
Documentation
Checklist